#include "woptions/woptions.h"

class Options : public woptions::ProgramOptions
{
public:
	enum overwrite_e
	{
		DEFAULT,
		OVERWRITE,
		PROMPT,
		SKIP
	};
	
	enum symlink_e
	{
		DONT_FOLLOW,
		FOLLOW_CMD_LINE,
		FOLLOW_ALL
	};

	Options() :
		recursive(false),
		overwrite(DEFAULT),
		preserve(false),
		verbose(false),
		symlink(DONT_FOLLOW)
	{
		//argument("cp",woptions::bind_argument_ignore());
		arguments("source_file",1,woptions::bind_argument_mem_fun(
			&source_files, &std::vector<std::string>::push_back));
		argument("target",woptions::bind_argument_var(target));
		
		option("-R","","Recursive.",
			woptions::bind_option_value(recursive,true));
		option("-H","","With -R, follow symbolic links on the command line.",
			woptions::bind_option_value(symlink,FOLLOW_CMD_LINE));
		option("-L","","With -R, follow all symbolic links.",
			woptions::bind_option_value(symlink,FOLLOW_ALL));
		option("-P","","With -R, never follow symbolic links.",
			woptions::bind_option_value(symlink,DONT_FOLLOW));
		option("-f","","Force overwrite.",woptions::bind_option_value(overwrite,OVERWRITE));
		option("-i","","Prompt on overwrite.",woptions::bind_option_value(overwrite,PROMPT));
		option("-n","","Never overwrite.",woptions::bind_option_value(overwrite,SKIP));
		option("-p","","Preserve as many properties as possible.",woptions::bind_option_value(preserve,true));
		option("-v","","Verbose output.",woptions::bind_option_value(verbose,true));
	}
	
	std::vector<std::string> source_files;
	std::string              target;
	bool                     recursive;
	overwrite_e              overwrite;
	bool                     preserve;
	bool                     verbose;
	symlink_e                symlink;
};

int main(int argc, char *argv[])
{
	Options opts;
	try
	{
		opts.parse(argc,argv);
		return 0;
	}
	catch(const woptions::ArgumentException& e)
	{
		opts.usage(argv[0]);
		std::cerr << e.what() << std::endl;
		return 1;
	}
}
